<template>
  <el-form-item label="调整礼品包库存" prop="addOrDeductionStockCount" :rules="rules">
    <count-adjust v-model:model-value="modelValue" :show-symbol="showSymbol"></count-adjust>
  </el-form-item>
</template>

<script lang="ts" setup>
import {WritableComputedRef} from "vue";
import {positiveInteger} from "@/utils/commonRegexp";
import CountAdjust from "@/components/goodsCenter/common/CountAdjust.vue";

const props = withDefaults(defineProps<{
  modelValue: number,
  showSymbol?: "+-" | "+" | "-"
}>(), {
  modelValue: 1,
  showSymbol: "+-"
})

const emits = defineEmits<{
  (e: 'update:model-value', value: number): void
}>()

const modelValue:WritableComputedRef<number> = computed({
  get() {
    return props.modelValue
  },
  set(newValue) {
    emits("update:model-value", newValue)
  }
})

const rules = [{
  required: true,
  trigger: 'blur',
  validator(rule: any, value: any, callback: any) {
    // if (!positiveInteger.test('' + props.modelValue)) {
    //   callback('礼品包库存需是正整数')
    // } else {
    // }
    callback()
  }
}]
</script>

<style scoped lang="scss">
@use "@/components/goodsCenter/styles/common.scss";

</style>
